#ifndef JSON_READER_H
#define JSON_READER_H

#include "JSON_parser.h"
#include "weakType/weak_type_value.h"
#include <stack>

namespace Json
{

typedef wolv::weakType::Value Value;

enum valueType
{
	nullType = wolv::weakType::nullType,
	intType = wolv::weakType::intType,
	boolType = wolv::weakType::boolType,
	doubleType = wolv::weakType::doubleType,
	stringType = wolv::weakType::stringType,
	arrayType = wolv::weakType::arrayType,
	objectType = wolv::weakType::objectType,
};


class Reader
{
public:
	Reader(int depth = -1);
	~Reader();

	
	int parse(const char* p, size_t length, Json::Value& value);
	int parse(std::string str, Json::Value& value);

private:
	static int _callback(void* ctx, int type, const JSON_value* value);
	
	int _parse(const char* p, size_t length,Json::Value& value);

	int _createParser();
	int _releaseParser();

	JSON_parser parser_;
	std::stack<Json::Value> stack_;
	std::stack<std::string> key_;
	int depth_;


	Reader(const Reader&);
	Reader& operator=(const Reader&);
};


}



#endif
